﻿using Data.Service.Service;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Data.Service
{
    public class Intelligence_AutoStockData
    {
        public static SYTDataBaseEntities db = new SYTDataBaseEntities();
        //获取橱窗设置
        public static Intelligence_AutoStock GetAutoStock(string memberId)
        {
            Intelligence_AutoStock autoStock = db.Intelligence_AutoStock.Where(M => M.MemberId == memberId).FirstOrDefault();

            if (autoStock != null)
            {
                return autoStock;
            }
            else
            {
                Intelligence_AutoStock newAutoStock = new Intelligence_AutoStock();
                newAutoStock.IsAutoStock = false;
                newAutoStock.IsAllProduct = true;
                newAutoStock.MemberId = memberId;
                newAutoStock.CreateTime = DateTime.Now;
                newAutoStock.UpdateTime = DateTime.Now;

                AddAutoStock(newAutoStock);//添加的数据库
                return newAutoStock;
            }
        }

        //修改数据
        public static bool UpdateAutoStock(Intelligence_AutoStock autoStock)
        {
            return BaseServer<Intelligence_AutoStock>.UpdateEntity(autoStock);
        }

        //添加一条数据
        public static bool AddAutoStock(Intelligence_AutoStock autoStock)
        {
            return BaseServer<Intelligence_AutoStock>.AddEntity(autoStock);
        }
    }
}
